package com.ruicar.afs.cloud.channel.common.feign;

import com.alibaba.fastjson.JSONObject;
import com.ruicar.afs.cloud.channel.blacklist.entity.BlacklistTemp;
import com.ruicar.afs.cloud.channel.cardealer.condition.CarDealerCondition;
import com.ruicar.afs.cloud.channel.cardealer.condition.ChangeSalesmanCondition;
import com.ruicar.afs.cloud.channel.cardealer.condition.DirectCarDealerCondition;
import com.ruicar.afs.cloud.channel.channelworkflow.condition.AccountToCaseCondition;
import com.ruicar.afs.cloud.channel.common.condition.BaseInfoTypeDTO;
import com.ruicar.afs.cloud.channel.common.condition.ChannelAffiliatedToCaseCondition;
import com.ruicar.afs.cloud.channel.common.condition.StatusCondition;
import com.ruicar.afs.cloud.channel.drawerparty.condition.DrawerPartyCondition;
import com.ruicar.afs.cloud.channel.online.condition.BatchManagerDTO;
import com.ruicar.afs.cloud.channel.online.condition.QuotaCondition;
import com.ruicar.afs.cloud.channel.online.entity.ChannelQuotaInfoTemp;
import com.ruicar.afs.cloud.channel.online.entity.ChannelReceivablesAccountTemp;
import com.ruicar.afs.cloud.channel.online.entity.ChannelRiskInfoTemp;
import com.ruicar.afs.cloud.channel.online.vo.ChannelQuotaInfoVo;
import com.ruicar.afs.cloud.channel.witness.entity.ChannelWitnessInfoTemp;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * @description: 请求案件服务
 * @author: panhj
 * @date: 2020/6/8 9:10
 */
@FeignClient(name = "case", url = "${com.greatwall.services.case-service.url}")
public interface ChannelUseCaseService {

    @PostMapping(value = "/witness/save")
    @ApiOperation("见证人保存或修改")
    IResponse getCaseSave(@RequestBody ChannelWitnessInfoTemp condition, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/witness/getWitness")
    @ApiOperation("见证人保存或修改")
    IResponse getWitness(@RequestBody ChannelWitnessInfoTemp condition, @RequestHeader Map<String, String> headers);


    /**
     * 修改状态
     *
     * @param ids
     * @param headers
     * @return
     */
    @PostMapping(value = "/caseChannel/upDateCaseStatusByIds/{ids}")
    @ApiOperation("根据id更新挂靠状态")
    public JSONObject upDateCaseStatusByIds(@PathVariable(value = "ids") String ids, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/caseChannel/upDateCaseStatusByIdsForApply")
    @ApiOperation("根据id更新挂靠状态")
    public JSONObject upDateCaseStatusByIdsForApply(@RequestBody String ids, @RequestHeader Map<String, String> headers);

    /**
     * 同步数据
     *
     * @param channelAffiliatedCondition
     * @param headers
     * @return
     */
    @PostMapping(value = "/caseChannel/saveThirdOrNetCar")
    @ApiOperation("同步案件数据")
    public IResponse saveThirdOrNetCar(@Valid @RequestBody ChannelAffiliatedToCaseCondition channelAffiliatedCondition, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/carDealer/upQuota")
    @ApiOperation("修改额度")
    IResponse upQuota(@RequestBody ChannelQuotaInfoVo vo, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/drawerParty/getDrawerPartyByIdType")
    @ApiOperation("通过纳税人识别号查询开票方")
    IResponse getDrawerPartyByIdType(@RequestBody BlacklistTemp black, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/channelCaseInfo/upStatusByChannel")
    @ApiOperation("根据id停用合作商或者直营车商状态")
    IResponse upStatusByChannel(@RequestBody List<Long> ids, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/caseChannel/upStatusByChannelIds")
    @ApiOperation("根据ids停用挂靠状态")
    IResponse upStatusByChannelIds(@RequestBody List<Long> ids, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/witness/upStatusWitnessByChannelIds")
    @ApiOperation("根据id停用见证人状态")
    IResponse upStatusWitnessByChannelIds(@RequestBody List<Long> ids, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/carDealer/upStatusCarDealerByChannelIds")
    @ApiOperation("根据id停用普通车商状态")
    IResponse upStatusCarDealerByChannelIds(@RequestBody List<Long> ids, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/channelCaseInfo/upStatusByChannelPass")
    @ApiOperation("根据id启用合作商或者直营车商状态")
    IResponse upStatusByChannelPass(@RequestBody List<Long> ids, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/caseChannel/upDateCaseStatusByIdsPass")
    @ApiOperation("根据id启用挂靠状态")
    IResponse upDateCaseStatusByIdsPass(@RequestBody List<Long> ids, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/witness/upStatusWitnessByChannelIdsPass")
    @ApiOperation("根据id启用见证人状态")
    IResponse upStatusWitnessByChannelIdsPass(@RequestBody List<Long> ids, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/drawerParty/upStatusDrawerByChannelIdsPass")
    @ApiOperation("根据id启用开票方状态")
    IResponse upStatusDrawerByChannelIdsPass(@RequestBody List<Long> ids, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/carDealer/upStatusCarDealerByChannelIdsPass")
    @ApiOperation("根据id停用普通车商状态")
    IResponse upStatusCarDealerByChannelIdsPass(@RequestBody List<Long> ids, @RequestHeader Map<String, String> headers);


    @PostMapping("/drawerParty/getByCondition")
    @ApiOperation(value = "多条件分页获取开票方")
    IResponse getDrawerPartys(@RequestBody DrawerPartyCondition condition, @RequestHeader Map<String, String> headers);

    @GetMapping("/drawerParty/getDrawerPartyById/{id}/{carDealerId}")
    @ApiOperation(value = "根据开票方id查询基本信息")
    IResponse getDrawerPartyById(@PathVariable(value = "id") String id, @PathVariable(value = "carDealerId") String carDealerId, @RequestHeader Map<String, String> headers);

    @GetMapping("/drawerParty/disableDrawerParty/{ids}")
    @ApiOperation(value = "禁用开票方")
    IResponse disableDrawerParty(@PathVariable(value = "ids") String[] ids, @RequestHeader Map<String, String> headers);

    @DeleteMapping("/drawerParty/delByIds/{id}")
    @ApiOperation(value = "删除开票方")
    IResponse deleteById(@PathVariable(value = "id") String id, @RequestHeader Map<String, String> headers);

    @GetMapping("/drawerParty/getCarDealerByChannelId/{id}")
    @ApiOperation(value = "根据渠道id查询车商信息")
    IResponse getCarDealerByChannelId(@PathVariable(value = "id") String id, @RequestHeader Map<String, String> headers);

    @PostMapping("/drawerParty/saveOrUpdateDrawerParty")
    @ApiOperation(value = "新增或更新开票方")
    IResponse saveOrUpdateDrawerParty(@RequestBody DrawerPartyCondition condition, @RequestHeader Map<String, String> headers);

    @PostMapping("/drawerParty/getDrawerPartyByChannel")
    @ApiOperation(value = "查询合作商下的开票方列表")
    IResponse getDrawerPartyByChannel(@RequestBody DrawerPartyCondition condition, @RequestHeader Map<String, String> headers);

    @PostMapping("/drawerParty/getAllSPChannels")
    @ApiOperation(value = "查询所有的SP和总对总")
    IResponse getAllSPChannels( DrawerPartyCondition condition,@RequestHeader Map<String, String> headers);

    @PostMapping("/carDealer/addCarDealer")
    @ApiOperation(value = "增加普通车商到案件服务")
    IResponse addCarDealer(@RequestBody CarDealerCondition condition, @RequestHeader Map<String, String> headers);

    @RequestMapping(value = "/carDealer/saveDirectCarDealer", method = RequestMethod.POST)
    @ApiOperation(value = "保存直营车商申请信息到案件服务")
    IResponse saveDirectCarDealer(DirectCarDealerCondition condition, @RequestHeader Map<String, String> headers);

    @PostMapping("/carDealer/savaInvoiceInfo")
    @ApiOperation(value = "保存开票信息到案件服务")
    IResponse savaInvoiceInfo(@RequestBody DirectCarDealerCondition condition, @RequestHeader Map<String, String> headers);

    @GetMapping("/carDealer/disableCarDealer/{ids}")
    @ApiOperation(value = "禁用案件中普通车商")
    IResponse diableCarDealer(@PathVariable(value = "ids") String[] ids, @RequestHeader Map<String, String> headers);


    @GetMapping("/carDealer/disableDirectCarDealer/{ids}")
    @ApiOperation(value = "禁用直营车商")
    IResponse disableDirectCarDealer(@PathVariable(value = "ids") String[] ids, @RequestHeader Map<String, String> headers);


    @GetMapping("/carDealer/bulkEditingSalesman/{salesman}/{ids}")
    @ApiOperation(value = "批量修改案件服务普通车商业务员")
    IResponse bulkEditingSalesman(@PathVariable(value = "salesman") String salesman, @PathVariable(value = "ids") String[] ids, @RequestHeader Map<String, String> headers);


    @PostMapping("/carDealer/bulkEditingCustomerManager")
    @ApiOperation(value = "批量修改案件服务直营车商城市经理")
    IResponse bulkEditingCustomerManager(ChangeSalesmanCondition condition, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/caseChannel/getBaseInfo")
    @ApiOperation("获取合作商")
    public IResponse getBaseInfo(@RequestBody StatusCondition statusCondition, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/caseChannel/getBaseInfoPage")
    @ApiOperation("分页获取合作商")
    public IResponse getBaseInfoPage(@RequestBody StatusCondition statusCondition, @RequestHeader Map<String, String> headers);

    @RequestMapping(value = "/carDealer/saveAccountInfo", method = RequestMethod.POST)
    @ApiOperation(value = "保存直营车商或渠道收款账号数据")
    IResponse saveAccountInfo(List<ChannelReceivablesAccountTemp> condition, @RequestHeader Map<String, String> headers);

    @RequestMapping(value = "/carDealer/saveCommonCarDealer", method = RequestMethod.POST)
    @ApiOperation(value = "保存普通车商申请信息")
    IResponse saveCommonCarDealer(CarDealerCondition condition, @RequestHeader Map<String, String> headers);

    @RequestMapping(value = "/carDealer/saveAccountInfoToCase", method = RequestMethod.POST)
    @ApiOperation(value = "保存直营车商或渠道收款账号数据")
    IResponse saveAccountInfoToCase(AccountToCaseCondition accountToCaseCondition, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/caseChannel/getBaseInfoByType")
    @ApiOperation("分页获取合作商")
    public IResponse getBaseInfoByType(@RequestBody BaseInfoTypeDTO dto, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/caseChannel/getBaseInfoByRole")
    @ApiOperation("根据角色属性查询渠道信息")
    public IResponse getBaseInfoByRole(@RequestBody BaseInfoTypeDTO dto, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/carDealer/batchManager")
    @ApiOperation("更新区域经理")
    public IResponse upCaseManager(@RequestBody BatchManagerDTO dto, @RequestHeader Map<String, String> headers);

    @PostMapping(value = "/channelQuota/recomputeChannelQuota")
    @ApiOperation("额度重算")
    List<ChannelQuotaInfoTemp> recomputeChannelQuota(QuotaCondition condition, @RequestHeader Map<String, String> headers);

    @GetMapping("/carDealer/disableCarDealerFromCase/{ids}/{channelId}/{status}")
    @ApiOperation(value = "停用案件端普通车商")
    IResponse disableCarDealerFromCase(@PathVariable(value = "ids") String[] ids, @PathVariable(value = "channelId") String channelId, @PathVariable(value = "status") String status, @RequestHeader Map<String, String> requestHeader);

    @GetMapping("/carDealer/disableDirectCarDealerFromApply/{ids}/{channelId}/{status}")
    @ApiOperation(value = "禁用案件端直营车商")
    IResponse disableDirectCarDealerFromApply(@PathVariable(value = "ids") String[] ids, @PathVariable(value = "channelId") String channelId,@PathVariable(value = "status") String status, @RequestHeader Map<String, String> requestHeader);

    @PostMapping(value = "/channelCaseInfo/updateGrade")
    @ApiOperation("更新案件端合作商评级")
    IResponse updateGrade(@RequestBody ChannelRiskInfoTemp channelRiskInfo, @RequestHeader Map<String, String> headers);
}
